//
//  HMHomeScrollView.m
//  LoveFreshBeen
//
//  Created by huodian on 16/10/15.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "HMHomeScrollView.h"

#import "HomeFocusModel.h"

#import <UIImageView+WebCache.h>

@interface HMHomeScrollView()

@property(nonatomic,copy)NSString* imageStr;

@property(nonatomic,strong)NSMutableArray* imageViewArray;

@end

@implementation HMHomeScrollView

-(NSMutableArray *)imageViewArray
{
    if (_imageViewArray == nil)
    {
        _imageViewArray = [NSMutableArray array];
    }
    return _imageViewArray;
    
    
}


-(void)setModelArray:(NSArray *)modelArray
{
    
    _modelArray = modelArray;
    
    
    for (int i = 0 ; i < self.imageViewArray.count; i++)
    {
        UIImageView* imageview = self.imageViewArray[i];
        
        HomeFocusModel* model = modelArray[i];
        
        NSURL* url = [NSURL URLWithString:model.img];
        
        [imageview sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"v2_placeholder_full_size"]];
        

    }
    
    
//     [modelArray enumerateObjectsUsingBlock:^(HomeFocusModel* obj, NSUInteger idx, BOOL * _Nonnull stop) {
//         
//         
//     }];
    
    [self layoutIfNeeded];
    
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        [self setMyUI];
   
        
    }
    return self;
}

-(void)setMyUI{
    
    int count = 5;
    
    UIScreen* screen = [UIScreen mainScreen];
    
    CGFloat imageWidth = screen.bounds.size.width;
    
//    self.contentSize = CGSizeMake(count * imageWidth , 150);
    
    
    for (int i = 0; i < count; i++) {
        UIImageView* imageView = [[UIImageView alloc]init];
        
        imageView.frame = CGRectMake(i *  imageWidth, 0, imageWidth, 150);
        
        imageView.image = [UIImage imageNamed:@"v2_placeholder_full_size"];
        
        [self.imageViewArray addObject:imageView];
        
        [self addSubview:imageView];
    }
    
   
        
        
//        NSURL* url = [NSURL URLWithString:obj.img];
//        
//        [imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"v2_placeholder_full_size"]];
        
  
      
        

    
  
    
    
    
    
    
}

@end
